<template>
    <el-breadcrumb class="app-breadcrumb" separator="/">
      <i class="el-icon-refresh" :style="'transform:rotate('+edeg+'deg)'" @click="refresh"></i>
    </el-breadcrumb>
</template>

<script>
export default {
  created() {
    this.getBreadcrumb()
  },
  data() {
    return {
      levelList: null,
      edeg:0
    }
  },
  watch: {
    $route() {
      this.getBreadcrumb()
    }
  },
  methods: {
    getBreadcrumb() {
      let matched = this.$route.matched.filter(item => item.name)
      const first = matched[0]
      if (first && first.name !== 'dashboard') {
        matched = [{ path: '/dashboard', meta: { title: 'Dashboard' }}].concat(matched)
      }
      this.levelList = matched
    },
    refresh() {
      this.edeg -= 360
      location.reload(true);
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  .app-breadcrumb.el-breadcrumb {
    display: inline-block;
    font-size: 14px;
    line-height: 50px;
    text-align: center;
    .no-redirect {
      color: #97a8be;
      cursor: text;
    }
    i{
      font-size: 21px;
      width: 25px;
      height: 50px;
      line-height: 49px;
      cursor: pointer;
    }
  }
  .el-icon-refresh{
    transform-origin: 50% 48%;
    transition: 0.5s;
  }
</style>
